package com.yonyou.pmclouds.problemlog.process;

import org.apache.commons.lang3.StringUtils;

import com.yonyou.pmclouds.basecom.bp.processor.SingleProcessor;
import com.yonyou.pmclouds.basecom.consts.BillTypeConst;
import com.yonyou.pmclouds.basecom.exception.BusinessException;
import com.yonyou.pmclouds.problemlog.entity.ProblemLogBillStatus;
import com.yonyou.pmclouds.problemlog.entity.ProblemLogVO;

/**
 * 问题记录单业务逻辑判断
 * @author fangpengc
 *
 */
public class ProblemLogBeforeAddProcess implements SingleProcessor<ProblemLogVO> {

    @Override
    public void process(ProblemLogVO vo, ProblemLogVO orig) throws BusinessException {
        if(vo == null) {
            throw new BusinessException("新增问题记录单为空,请检查!");
        } else if(StringUtils.isEmpty(vo.getPk_rectificationer())) {
            throw new BusinessException("整改人为空");
        } else if(StringUtils.isEmpty(vo.getPk_problemreason())) {
            throw new BusinessException("问题原因为空");
        }
        // 设置单据类型
        vo.setBill_type(BillTypeConst.PROBLEMLOG_BILLTYPE);
        vo.setBillstatus(ProblemLogBillStatus.STATUS_REPAIRING);
    }

}
